package com.elm.controller;

import com.elm.po.Business;
import com.elm.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/business")
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    @GetMapping("/getBusinessByOrderTypeId")
    public List<Business> getBusinessByOrderTypeId(@PathVariable Integer orderTypeId) {
        return businessService.getBusinessByOrderTypeId(orderTypeId);
    }

    @GetMapping("/getBusinessById")
    public Business getBusinessById(@PathVariable Integer businessId) {
        return businessService.getBusinessById(businessId);
    }

    @GetMapping("/getBusinessBySales")
    public List<Business> getBusinessBySales() { 
        return businessService.getBusinessBySales();
    }

    @GetMapping("/getBusinessByStar")
    public List<Business> getBusinessByStar() {
        return businessService.getBusinessByStar();
    }

    @GetMapping("/getAllReviewingBusiness")
    public List<Business> getAllReviewingBusiness() {
        return businessService.getAllReviewingBusiness();
    }

    @PutMapping("/updateReviewingBusinessInfo")
    public Integer updateReviewingBusinessInfo(@PathVariable Integer businessId, @RequestParam boolean result) {
        return businessService.updateReviewingBusinessInfo(businessId, result);
    }

    @PostMapping("/createBusiness")
    public Integer createBusiness(@RequestBody Business business) {
        return businessService.createBusiness(business);
    }

    @PutMapping("/updateBusiness")
    public Integer updateBusiness(@RequestBody Business business) {
        return businessService.updateBusiness(business);
    }

    @PutMapping("/updateBusinessStatus")
    public Integer updateBusinessStatus(@RequestBody Business business) {
        return businessService.updateBusinessStatus(business);
    }
}